#import "UITextView+Filter.h"

@implementation UITextView (UITextView_Filter)

- (void)filterTextFieldLength:(int)length
{
    UITextRange *selectedRange = [self markedTextRange];
    if ((selectedRange == nil || selectedRange.empty) && self.text.length > length) {
        self.text = [self.text substringToIndex:length];
    }
}

- (void)filterTextFieldSelected
{
    UITextRange *selectedRange = [self markedTextRange];
    if (selectedRange != nil && !selectedRange.empty) {
        [self replaceRange:selectedRange withText:@""];
    }
}

@end
